<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:c="http://java.sun.com/jsp/jstl/core"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:composite="http://java.sun.com/jsf/composite"
	xmlns:p="http://primefaces.org/ui">

<composite:interface>
	<composite:attribute name="widgetVar"
		default="_#{cc.clientId.replace(':', '_')}_dialog" />
	<composite:attribute name="rendered" default="true" />
	<composite:attribute name="draggable" default="true" />
	<composite:attribute name="resizable" default="true" />
	<composite:attribute name="modal" default="true" />
	<composite:attribute name="visible" default="false" />
	<composite:attribute name="width" default="500" />
	<composite:attribute name="height" default="auto" />
	<composite:attribute name="minWidth" default="150" />
	<composite:attribute name="minHeight" default="0" />
	<composite:attribute name="style" />
	<composite:attribute name="styleClass" />
	<composite:attribute name="showEffect" default="fade" />
	<composite:attribute name="hideEffect" default="fade" />
	<composite:attribute name="position" />
	<composite:attribute name="closable" default="true" />
	<composite:attribute name="onShow" />
	<composite:attribute name="onHide" />
	<composite:attribute name="appendTo" default="" />
	<composite:attribute name="showHeader" default="true" />
	<composite:attribute name="footer" default="" />
	<composite:attribute name="dynamic" default="true" />
	<composite:attribute name="minimizable" default="false" />
	<composite:attribute name="closeOnEscape" default="false" />
	<composite:attribute name="focus" />
	<composite:attribute name="fitViewport" default="false" />
	<composite:attribute name="positionType" default="fixed" />
	<composite:attribute name="responsive" default="false" />

	<!-- coustom attrs-->
	<!-- close dialog-->
	<composite:attribute name="closeAjaxSupported" default="true" />
	<composite:attribute name="closeListener"
		method-signature="void close(javax.faces.component.UIComponent)"
		default="#{controller.resetForm(component)}" />
	<composite:attribute name="closeUpdate" default="@none" />
	<composite:attribute name="closeOncomplete" />
	<!-- save button-->
	<composite:attribute name="saveSupported" default="true" />
	<composite:attribute name="saveDisabled" default="true" />
	<composite:attribute name="saveButtonText"
		default="#{msg['framework']['sure']}" />
	<composite:attribute name="saveMethod" method-signature="void save()"
		default="#{controller.save}" />
	<composite:attribute name="saveUpdate" default="@none" />
	<!-- cancel button-->
	<composite:attribute name="cancelSupported" default="true" />
	<composite:attribute name="cancelButtonText"
		default="#{msg['framework']['cancel']}" />
	<composite:attribute name="cancelMethod"
		method-signature="void cancel(javax.faces.component.UIComponent)"
		default="#{controller.resetForm(component)}" />
	<composite:attribute name="cancelUpdate" default="@none" />
	<composite:attribute name="cancelOncomplete"
		default="PF('#{cc.attrs.widgetVar}').hide();" />

	<!-- other attrs -->
	<composite:attribute name="dialogContentStyleClass" />
	<composite:attribute name="showMessages" default="true" />


	<composite:facet name="button" />
</composite:interface>

<composite:implementation>
	<p:dialog id="entityDialog" rendered="#{cc.attrs.rendered}"
		widgetVar="#{cc.attrs.widgetVar}" header="#{cc.attrs.header}"
		draggable="#{cc.attrs.draggable}" resizable="#{cc.attrs.resizable}"
		modal="#{cc.attrs.modal}" visible="#{cc.attrs.visible}"
		width="#{cc.attrs.width}" height="#{cc.attrs.height}"
		minWidth="#{cc.attrs.minWidth}" minHeight="#{cc.attrs.minHeight}"
		style="#{cc.attrs.style}"
		styleClass="entity-dialog #{cc.attrs.styleClass}"
		showEffect="#{cc.attrs.showEffect}"
		hideEffect="#{cc.attrs.hideEffect}" position="#{cc.attrs.position}"
		closable="#{cc.attrs.closable}" onShow="#{cc.attrs.onShow}"
		onHide="#{cc.attrs.onHide}" appendTo="#{cc.attrs.appendTo}"
		showHeader="#{cc.attrs.showHeader}" footer="#{cc.attrs.footer}"
		dynamic="#{cc.attrs.dynamic}" minimizable="#{cc.attrs.minimizable}"
		maximizable="#{cc.attrs.maximizable}"
		closeOnEscape="#{cc.attrs.closeOnEscape}" focus="#{cc.attrs.focus}"
		fitViewport="#{cc.attrs.fitViewport}"
		positionType="#{cc.attrs.positionType}"
		responsive="#{cc.attrs.responsive}">

		<composite:insertFacet name="header" />


		<h:panelGrid id="contentPanel" cellspacing="0" cellpadding="0"
			width="100%"
			styleClass="dialog-content-datagrid #{cc.attrs.dialogContentStyleClass}">
			<p:messages id="messages" showDetail="true" showSummary="false"
				rendered="#{cc.attrs.showMessages}" severity="error" />

			<composite:insertChildren />
		</h:panelGrid>

		<f:facet name="footer">
			<composite:renderFacet name="button" />
			<p:outputPanel rendered="#{cc.attrs.cancelSupported}" layout="inline">
				<p:commandButton id="cancelButton"
					value="#{cc.attrs.cancelButtonText}"
					styleClass="entity-dialog-cancel-btn secondary-button"
					immediate="true" process="@this" action="#{cc.attrs.cancelMethod}"
					update="#{cc.attrs.cancelUpdate}"
					oncomplete="#{cc.attrs.cancelOncomplete}" />
			</p:outputPanel>
			<p:outputPanel rendered="#{cc.attrs.saveSupported}" layout="inline">
				<p:commandButton id="saveButton" styleClass="entity-dialog-save-btn"
					value="#{cc.attrs.saveButtonText}" action="#{cc.attrs.saveMethod}"
					disabled="#{cc.attrs.saveDisabled}"
					update=":#{cc.clientId}:contentPanel, #{cc.attrs.saveUpdate}"
					oncomplete="if (!args.validationFailed) PF('#{cc.attrs.widgetVar}').hide();" />
			</p:outputPanel>
		</f:facet>

		<c:if test="#{cc.attrs.closeAjaxSupported}">
			<p:ajax event="close" process="@this" global="true"
				listener="#{cc.attrs.closeListener}"
				update="#{cc.attrs.closeUpdate}"
				oncomplete="#{cc.attrs.closeOncomplete}" />
		</c:if>
	</p:dialog>
</composite:implementation>
</html>
